
import {
    Route,
    Switch,
    Link,
} from 'react-router-dom'

import Home from './home'
import About from './about'
import Users from './users'
export default  (props)=>{
   // console.log(props);
    let toUsers=()=>{
        //props.history.push("/users") 
        //props.history.replace("/users")
        //rest风格
        /* props.history.push("/users/10086/张三") */
      //查询字符串
       // props.history.push("/users?stuid=10086&stuname=张三")
       //state传值
       props.history.push({
           pathname:"/main/users",
           state:{
              stuid:2000,
              stuname:"李四" 
           }
       })
    }

    return(
     <div>
       <div>
           <ul>
               <li>
                   <Link   to="/main/home">Home</Link>
               </li>
               <li>
               <Link   replace={true} to="/main/about" >About</Link>
               </li>
               <li>
                   <button  onClick={toUsers}>跳转到users</button>   
               </li>
           </ul>
        </div>
          <hr></hr>
       <div>
        <Switch>
            <Route path="/main/home"  component={Home} ></Route>            <Route path="/main/about" component={About} ></Route>
{/*           <Route path="/users/:id/:stuName" component={Users} ></Route>
 */}          
         <Route path="/main/users" component={Users}></Route>
         </Switch>
       </div>
       </div>
    )
}